home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2001 May / SGI IRIX Base Documentation 2001 May.iso / usr / share / catman / p_man / cat3 / librw / RWpostream.z / RWpostream
Encoding:
Text File  |  1998-10-30  |  20.3 KB  |  463 lines

  1.  
  2.  
  3.  
  4. RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  5.  
  6.  
  7.  
  8. NNNNaaaammmmeeee
  9.      RWpostream - Rogue Wave library class
  10.  
  11. SSSSyyyynnnnooooppppssssiiiissss
  12.               #include <rw/pstream.h>
  13.  
  14.  
  15.  
  16.               // Construct an RWpostream, using cout's streambuf:
  17.           RWpostream pstr(cout) ;
  18.  
  19.  
  20.  
  21.  
  22. DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn
  23.      Class RRRRWWWWppppoooossssttttrrrreeeeaaaammmm specializes the abstract base class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm to store
  24.      variables in a portable (printable) ASCII format.  The results can be
  25.      restored by using its counterpart RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm.  You can think of
  26.      RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm and RRRRWWWWppppoooossssttttrrrreeeeaaaammmm as an ASCII veneer over an associated streambuf
  27.      which are responsible for formatting variables and escaping characters
  28.      such that the results can be interchanged between any machines.  As such,
  29.      they are slower than their binary counterparts RRRRWWWWbbbbiiiissssttttrrrreeeeaaaammmm and RRRRWWWWbbbboooossssttttrrrreeeeaaaammmm
  30.      which are more machine dependent.  Because RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm and RRRRWWWWppppoooossssttttrrrreeeeaaaammmm
  31.      retain no information about the state of their associated ssssttttrrrreeeeaaaammmmbbbbuuuuffffs,
  32.      their use can be freely exchanged with other users of the ssssttttrrrreeeeaaaammmmbbbbuuuuffff (such
  33.      as iiiissssttttrrrreeeeaaaammmm or iiiiffffssssttttrrrreeeeaaaammmm).  The goal of class RRRRWWWWppppoooossssttttrrrreeeeaaaammmm and RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm is
  34.      to store variables using nothing but printable ASCII characters.  Hence,
  35.      nonprintable characters must be converted into an external representation
  36.      where they can be recognized.  Furthermore, other characters may be
  37.      merely bit values (a bit image, for example), having nothing to do with
  38.      characters as symbols.  For example,
  39.  
  40.               RWpostream pstrm(cout);
  41.  
  42.  
  43.  
  44.               char c = '0;
  45.           pstr << c;     // Stores "newline"
  46.           pstr.put_;     // Stores the number 10.
  47.  
  48.  
  49.      The expression "ppppssssttttrrrr <<<<<<<< cccc" treats cccc as a symbol for a newline, an
  50.      unprintable character.  The expression "ppppssssttttrrrr....ppppuuuutttt____" treats cccc as the
  51.      literal number "10".  NNNNooootttteeee tttthhhhaaaatttt vvvvaaaarrrriiiiaaaabbbblllleeeessss sssshhhhoooouuuulllldddd nnnnooootttt bbbbeeee sssseeeeppppaaaarrrraaaatttteeeedddd wwwwiiiitttthhhh
  52.      wwwwhhhhiiiitttteeee ssssppppaaaacccceeee.  Such white space would be interpreted literally and would
  53.      have to be read back in as a character string.  RRRRWWWWppppoooossssttttrrrreeeeaaaammmm can be
  54.      interrogated as to the stream state using member functions ggggoooooooodddd(((()))), bbbbaaaadddd(((()))),
  55.      eeeeooooffff(((()))),pppprrrreeeecccciiiissssiiiioooonnnn(((()))), eeeettttcccc.
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  71.  
  72.  
  73.  
  74. Persistence
  75.      None
  76.  
  77. EEEExxxxaaaammmmpppplllleeee
  78.      See RRRRWWWWppppiiiissssttttrrrreeeeaaaammmm for an example of how to read back in the results of this
  79.      program.  The symbol "o" is intended to represent a control-G, or bell.
  80.  
  81.  
  82.  
  83.  
  84.  
  85.               .cpp
  86.           #include <rw/pstream.h>
  87.           main(){
  88.              // Construct an RWpostream to use standard output:
  89.              RWpostream pstr(cout);
  90.             int i = 5;
  91.              float f = 22.1;
  92.              double d = -0.05;
  93.              char string[]
  94.                      = "A string withtabs,0ewlines and a o bell.";
  95.              pstr << i;        // Store an int in binary
  96.              pstr << f << d;   // Store a float & double
  97.              pstr << string;   // Store a string
  98.           }
  99.  
  100.  
  101.      PPPPrrrrooooggggrrrraaaammmm oooouuuuttttppppuuuutttt::::
  102.  
  103.               5
  104.           22.1
  105.           -0.05
  106.           "A string withtabs,0ewlines and a bell."
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117. PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss
  118.               RRRRWWWWppppoooossssttttrrrreeeeaaaammmm(streambuf* s);
  119.  
  120.  
  121.      Initialize an RRRRWWWWppppoooossssttttrrrreeeeaaaammmm from the ssssttttrrrreeeeaaaammmmbbbbuuuuffff ssss.
  122.  
  123.               RRRRWWWWppppoooossssttttrrrreeeeaaaammmm(ostream& str);
  124.  
  125.  
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  137.  
  138.  
  139.  
  140.      Initialize an RRRRWWWWppppoooossssttttrrrreeeeaaaammmm from the ssssttttrrrreeeeaaaammmmbbbbuuuuffff associated with the output
  141.      stream ssssttttrrrr.
  142.  
  143. PPPPuuuubbbblllliiiicccc DDDDeeeessssttttrrrruuuuccccttttoooorrrr
  144.               virtual ~~~~RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm();
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.      This virtual destructor allows specializing classes to deallocate any
  152.      resources that they may have allocated.
  153.  
  154. PPPPuuuubbbblllliiiicccc OOOOppppeeeerrrraaaattttoooorrrrssss
  155.               virtual RWvostream&
  156.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(const char* s);
  157.  
  158.  
  159.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the character string starting at
  160.      ssss to the output stream using a portable format.  The character string is
  161.      expected to be null terminated.
  162.  
  163.               virtual RWvostream&
  164.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(const wchar_t* ws);
  165.  
  166.  
  167.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the wide character string
  168.      starting at wwwwssss to the output stream using a portable format.  The
  169.      character string is expected to be null terminated.
  170.  
  171.               virtual RWvostream&
  172.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(char c);
  173.  
  174.  
  175.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the char cccc to the output stream
  176.      using a portable format.  Note that cccc is treated as a character, not a
  177.      number. This member attempts to preserve the symbolic characters values
  178.      transmitted over the stream
  179.  
  180.               virtual RWvostream&
  181.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(wchar_t wc);
  182.  
  183.  
  184.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the wwwwiiiiddddeeee cccchhhhaaaarrrr wwwwcccc to the output
  185.      stream using a portable format.  Note that wwwwcccc is treated as a character,
  186.      not a number.
  187.  
  188.               virtual RWvostream&
  189.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned char c);
  190.  
  191.  
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  203.  
  204.  
  205.  
  206.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrr cccc to the output
  207.      stream using a portable format.  Note that cccc is treated as a character,
  208.      not a number.
  209.  
  210.               virtual RWvostream&
  211.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(double d);
  212.  
  213.  
  214.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the ddddoooouuuubbbblllleeee dddd to the output stream
  215.      using a portable format.
  216.  
  217.               virtual RWvostream&
  218.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(float f);
  219.  
  220.  
  221.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the ffffllllooooaaaatttt ffff to the output stream
  222.      using a portable format.
  223.  
  224.               virtual RWvostream&
  225.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(int i);
  226.  
  227.  
  228.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the iiiinnnntttt iiii to the output stream
  229.      using a portable format.
  230.  
  231.               virtual RWvostream&
  232.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned int i);
  233.  
  234.  
  235.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttt iiii to the output
  236.      stream using a portable format.
  237.  
  238.               virtual RWvostream&
  239.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(long l);
  240.  
  241.  
  242.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the lllloooonnnngggg llll to the output stream
  243.      using a portable format.
  244.  
  245.               virtual RWvostream&
  246.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned long l);
  247.  
  248.  
  249.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnngggg llll to the output
  250.      stream using a portable format.
  251.  
  252.               virtual RWvostream&
  253.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(short s);
  254.  
  255.  
  256.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the sssshhhhoooorrrrtttt ssss to the output stream
  257.      using a portable format.
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  269.  
  270.  
  271.  
  272.               virtual RWvostream&
  273.           ooooppppeeeerrrraaaattttoooorrrr<<<<<<<<(unsigned short s);
  274.  
  275.  
  276.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttt ssss to the
  277.      output stream using a portable format.
  278.  
  279.               ooooppppeeeerrrraaaattttoooorrrr vvvvooooiiiidddd****();
  280.  
  281.  
  282.      Inherited via RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm from RRRRWWWWvvvviiiioooossss.
  283.  
  284. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss
  285.               int
  286.           pppprrrreeeecccciiiissssiiiioooonnnn() const;
  287.  
  288.  
  289.      Returns the currently set precision used for writing ffffllllooooaaaatttt and ddddoooouuuubbbblllleeee
  290.      data.  At construction, the precision is set to RRRRWWWW____DDDDEEEEFFFFAAAAUUUULLLLTTTT____PPPPRRRREEEECCCCIIIISSSSIIIIOOOONNNN
  291.      (defined in ccccoooommmmppppiiiilllleeeerrrr....hhhh.)
  292.  
  293.               int
  294.           pppprrrreeeecccciiiissssiiiioooonnnn(int p);
  295.  
  296.  
  297.      Changes the precision used for writing ffffllllooooaaaatttt and ddddoooouuuubbbblllleeee data.  Returns
  298.      the previously set precision.  At construction, the precision is set to
  299.      RRRRWWWW____DDDDEEEEFFFFAAAAUUUULLLLTTTT____PPPPRRRREEEECCCCIIIISSSSIIIIOOOONNNN  (defined in ccccoooommmmppppiiiilllleeeerrrr....hhhh.)
  300.  
  301.               virtual RWvostream&
  302.           fffflllluuuusssshhhh();
  303.  
  304.  
  305.      Send the contents of the stream buffer to output immediately.
  306.  
  307.               virtual RWvostream&
  308.           ppppuuuutttt(char c);
  309.  
  310.  
  311.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the cccchhhhaaaarrrr cccc to the output stream,
  312.      preserving its value using a portable format. This member only preserves
  313.      ASCII numerical codes, not the coresponding character symbol.
  314.  
  315.               virtual RWvostream&
  316.           ppppuuuutttt(wchar_t wc);
  317.  
  318.  
  319.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the wide character wwwwcccc to the
  320.      output stream, preserving its value using a portable format.
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  335.  
  336.  
  337.  
  338.               virtual RWvostream&
  339.           ppppuuuutttt(unsigned char c);
  340.  
  341.  
  342.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrr cccc to the output
  343.      stream, preserving its value using a portable format.
  344.  
  345.               virtual RWvostream&
  346.           ppppuuuutttt(const char* p, size_t N);
  347.  
  348.  
  349.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of cccchhhhaaaarrrrs starting at pppp
  350.      to the output stream, preserving their values using a portable format.
  351.      Note that the characters will be treated as literal numbers (i.e., not as
  352.      a character string).
  353.  
  354.               virtual RWvostream&
  355.           ppppuuuutttt(const wchar_t* p, size_t N);
  356.  
  357.  
  358.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of wide cccchhhhaaaarrrrs starting
  359.      at pppp to the output stream, preserving their values using a portable
  360.      format.  Note that the characters will be treated as literal numbers
  361.      (i.e., not as a character string).
  362.  
  363.               virtual RWvostream&
  364.           ppppuuuutttt(const unsigned char* p, size_t N);
  365.  
  366.  
  367.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of uuuunnnnssssiiiiggggnnnneeeedddd cccchhhhaaaarrrrs
  368.      starting at pppp to the output stream using a portable format.  The
  369.      characters should be treated as literal numbers (i.e., not as a character
  370.      string).
  371.  
  372.               virtual RWvostream&
  373.           ppppuuuutttt(const short* p, size_t N);
  374.  
  375.  
  376.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of sssshhhhoooorrrrtttts starting at
  377.      pppp to the output stream using a portable format.
  378.  
  379.               virtual RWvostream&
  380.           ppppuuuutttt(const unsigned short* p, size_t N);
  381.  
  382.  
  383.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of uuuunnnnssssiiiiggggnnnneeeedddd sssshhhhoooorrrrtttts
  384.      starting at pppp to the output stream using a portable format.
  385.  
  386.               virtual RWvostream&
  387.           ppppuuuutttt(const int* p, size_t N);
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))                                              RRRRWWWWppppoooossssttttrrrreeeeaaaammmm((((3333CCCC++++++++))))
  401.  
  402.  
  403.  
  404.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of iiiinnnntttts starting at pppp
  405.      to the output stream using a portable format.
  406.  
  407.               virtual RWvostream&
  408.           ppppuuuutttt(const unsigned int* p, size_t N);
  409.  
  410.  
  411.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of uuuunnnnssssiiiiggggnnnneeeedddd iiiinnnntttts
  412.      starting at pppp to the output stream using a portable format.
  413.  
  414.               virtual RWvostream&
  415.           ppppuuuutttt(const long* p, size_t N);
  416.  
  417.  
  418.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of lllloooonnnnggggs starting at pppp
  419.      to the output stream using a portable format.
  420.  
  421.               virtual RWvostream&
  422.           ppppuuuutttt(const unsigned long* p, size_t N);
  423.  
  424.  
  425.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of uuuunnnnssssiiiiggggnnnneeeedddd lllloooonnnnggggs
  426.      starting at pppp to the output stream using a portable format.
  427.  
  428.               virtual RWvostream&
  429.           ppppuuuutttt(const float* p, size_t N);
  430.  
  431.  
  432.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of ffffllllooooaaaatttts starting at
  433.      pppp to the output stream using a portable format.
  434.  
  435.               virtual RWvostream&
  436.           ppppuuuutttt(const double* p, size_t N);
  437.  
  438.  
  439.      Redefined from class RRRRWWWWvvvvoooossssttttrrrreeeeaaaammmm.  Store the vector of ddddoooouuuubbbblllleeees starting at
  440.      pppp to the output stream using a portable format.
  441.  
  442.               virtual RWvostream&
  443.           ppppuuuuttttSSSSttttrrrriiiinnnngggg(const char*s, size_t N);
  444.  
  445.  
  446.      Store the character string, iiiinnnncccclllluuuuddddiiiinnnngggg eeeemmmmbbbbeeeeddddddddeeeedddd nnnnuuuullllllllssss, starting at s to
  447.      the output string.
  448.  
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.